﻿using System;
using System.IO;
using System.Web;
using RabbitManage.Code;

namespace RabbitManage.Action
{
    public partial class ImageUp : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            HttpCookie cookie = Request.Cookies[Constant.CookieName];
            string shopId = cookie.Values[Constant.CookieUid];

            HttpFileCollection hfc = HttpContext.Current.Request.Files;
            if (hfc.Count > 0)
            {
                HttpPostedFile hpf = hfc[0];
                string dir = HttpContext.Current.Server.MapPath("../UploadSpace/" + shopId + "/");
                if (!Directory.Exists(dir))
                {
                    Directory.CreateDirectory(dir);
                }
                hpf.SaveAs(dir + hpf.FileName);

                Response.Redirect("/UI/ImageList.aspx", false);
            }
            
        }
    }
}